package com.qfedu.service.impl;

import com.qfedu.dao.CartDao;
import com.qfedu.dao.impl.CartDaoImpl;
import com.qfedu.dao1.CartDaoByMybatis;
import com.qfedu.entity.Cart;
import com.qfedu.service.CartService;
import com.qfedu.utils.MyBatisUtils;

import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.sql.SQLException;
import java.util.List;

public class CartServiceImpl implements CartService {
    private CartDao cartDao = new CartDaoImpl();
    private CartDaoByMybatis cartDaoByMybatis = MyBatisUtils.getSqlSession().getMapper(CartDaoByMybatis.class);

    @Override
    public Cart getCartById(int uid, int pid) throws IllegalAccessException, SQLException, InvocationTargetException {
        return cartDaoByMybatis.getCartById(uid, pid);
    }

    @Override
    public int addCart(int uid, int pid, int cnum, BigDecimal ccount) throws SQLException {
        return cartDaoByMybatis.addCart(uid, pid, cnum, ccount);
    }

    @Override
    public int update(int cnum, BigDecimal ccount, int cid) throws SQLException {
        return cartDaoByMybatis.update(cnum, ccount, cid);
    }

    @Override
    public List<Cart> getCartListByUid(int uid) throws IllegalAccessException, SQLException, InvocationTargetException {
        return cartDaoByMybatis.getCartListByUid(uid);
    }

    @Override
    public int delete(int cid) throws SQLException {
        return cartDaoByMybatis.delete(cid);
    }

    @Override
    public int deleteCart(int uid) throws SQLException {
        return cartDaoByMybatis.deleteCart(uid);
    }
//    @Override
//    public Cart getCartById(int uid, int pid) throws SQLException, InvocationTargetException, IllegalAccessException {
//        return cartDao.getCartById(uid, pid);
//    }
//
//    @Override
//    public int addCart(int uid, int pid, int cnum, BigDecimal ccount) throws SQLException {
//        return cartDao.addCart(uid,pid,cnum,ccount);
//    }
//
//    @Override
//    public int update(int cnum, BigDecimal ccount, int cid) throws SQLException {
//        return cartDao.update(cnum,ccount,cid);
//    }
//
//
//    @Override
//    public List<Cart> getCartListByUid(int uid) throws SQLException, InvocationTargetException, IllegalAccessException {
//        return cartDao.getCartListByUid(uid);
//    }
//
//    @Override
//    public int delete(int cid) throws SQLException {
//        return cartDao.delete(cid);
//    }
//
//    @Override
//    public int deleteCart(int uid) throws SQLException {
//        return cartDao.deleteCart(uid);
//    }
}
